from sqlalchemy import Column, Integer, String, TIMESTAMP, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import os

Base = declarative_base()


class BotUser(Base):
    __tablename__ = "botuser"
    id = Column(Integer, primary_key=True, autoincrement=True)
    username = Column(String(255), nullable=False)
    birthday = Column(TIMESTAMP, nullable=False)


path = f"postgresql://{os.environ.get('POSTGRES_USER')}:{os.environ.get('POSTGRES_PASSWORD')}@postgres/bdbot"
engine = create_engine(path, echo=True)
Session = sessionmaker(bind=engine)
session = Session()